package xinxin.com.ObserverPattern;

import xinxin.com.ObserverPattern.Observer.Detail.NBAObserver;
import xinxin.com.ObserverPattern.Observer.Observer;
import xinxin.com.ObserverPattern.Subject.Detail.Boss;
import xinxin.com.ObserverPattern.Subject.Detail.Secretary;
import xinxin.com.ObserverPattern.Observer.Detail.StockObserver;
import xinxin.com.ObserverPattern.Subject.Subject;

public class ObserverPattern {
    public static void main(String[] args) {
        Subject secretary = new Secretary();
        Subject boss = new Boss();
        Observer tongshi1 = new StockObserver("史鑫鑫", boss);
        Observer tongshi2 = new NBAObserver("张梓锐", boss);
        Observer tongshi3 = new NBAObserver("李皓琪", boss);

        secretary.Attach(tongshi1);
        secretary.Attach(tongshi2);
        secretary.Attach(tongshi3);

        boss.Attach(tongshi1);
        boss.Attach(tongshi2);
        boss.Attach(tongshi3);

        boss.Detach(tongshi3);

        // secretary.setAction("老板回来了");
        boss.setAction("我胡汉三回来了");

        boss.Notify();
    }
}
